package com.android.aiod.ui.activity;

import android.content.Context;
import android.content.Intent;
import com.android.baselibrary.interface_.CommCallBack;
import com.android.baselibrary.view.Comm_HeadView;
import com.android.aiod.R;
import com.android.aiod.ui.fragment.WebView_Fragment;

import butterknife.BindView;


/**
 * Created by Administrator on 2018/6/20.
 */
public class WebViewActivity extends BaseActivity {

    @BindView(R.id.comm_title)
    Comm_HeadView comm_title;

    WebView_Fragment fragment;

    public static void startActivity(Context context, String title, String url) {
        Intent intent = new Intent(context,  WebViewActivity.class);
        intent.putExtra("title", title);
        intent.putExtra("url", url);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_mywebview;
    }

    @Override
    protected void initView() {
        String title = getIntent().getStringExtra("title");
        String url = getIntent().getStringExtra("url");

        fragment = new WebView_Fragment();
        fragment.setUrl(url);
        fragment.callBack = new CommCallBack() {
            @Override
            public void onResult(Object obj) {
                comm_title.setTitle((String) obj);
            }
        };
        getSupportFragmentManager().beginTransaction().add(R.id.framelayout, fragment).commit();
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onBackPressed() {
        if (fragment.onBackPressed()) {

        } else {
            super.onBackPressed();
        }
    }
}
